home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / cisco / cisco-expect.shar / ciscoconfigure < prev    next >
Encoding:
Text File  |  1992-08-07  |  1.2 KB  |  60 lines

  1. #!/usr/local/bin/expect -f
  2. #
  3. # Fetch configuration information from the specified cisco router
  4. #
  5. # args: ciscoget router passwd enablepasswd filename
  6. #
  7. set localhost [exec hostname]
  8. set tftpdir /private/tftpboot
  9.  
  10. set router [index $argv 1]
  11. set password [index $argv 2]
  12. set enablepass [index $argv 3]
  13. set filename [index $argv 4]
  14.  
  15. proc timedout {args} {
  16.     send_user "Expect timed out" $args \n
  17.     exit
  18. }
  19.  
  20. source ciscologin.expect
  21.  
  22. if {[length $argv] < 5} {
  23.     print "Invalid number of arguments\n"
  24.     exit
  25. }
  26.  
  27. send_user \n\n\n
  28. spawn telnet $router
  29. login $enablepass
  30. send configure network\r
  31.  
  32. expect {*configuration\ file*\?\ } {} \
  33.     timeout        {timedout waiting for config file prompt}
  34.  
  35. send network\r
  36. expect {*IP\ address\ of\ remote\ host*\?\ } {} \
  37.     timeout        {timedout waiting for remote host prompt}
  38.  
  39. send $localhost
  40.  
  41. expect {*configuration\ file*?\ } {} \
  42.     timeout        {timedout waiting for filename prompt}
  43.  
  44. send ${filename}\r
  45.  
  46. expect {*Configure\ using*\[confirm\]*} {} \
  47.     timeout        {timedout waiting for confirm}
  48.  
  49. send "Y"
  50.  
  51. expect    {*Failed*#}    {send_user TFTP get failed\n; exit 1} \
  52.     {*OK*#}        {send_user TFTP get succeeded\n}
  53.  
  54. send "write\r"
  55. expect {*\[OK\]*} {} \
  56.     timeout  {send_user Write failed\n; exit 1}
  57. send QUIT\r
  58. expect *Closed*
  59. exit 0
  60.